import fa from "element-ui/src/locale/lang/fa";

export default {
  state: {
    // 登录用户所拥有权限的全部菜单
    menu: [],
    openedTab:[],
    isActive:''
  },
  // 监听state更新
  getters: {
    getIsActive(state){
      return state.isActive
    }
  },
  // 操作state
  mutations: {
    // 获取侧边栏数据
    getAllMenu (state, obj) {
    return state.menu = obj;
    },
    //添加标签
    selectMenu(state,obj){
      //标签确保唯一
      let flag = true;
      const list = state.openedTab;
      for (let i of list){
        if (i.path === obj.path){
          return  flag = false;
        }
      }
      if (flag){list.push(obj);}

    },
    //删除标签
    delOpenTab(state,name){
      const list = state.openedTab;
      list.forEach((item,index)=>{
        if (item.label === name){
            list.splice(index,1);
        }
      })
    },
    //设置活动中的标签
    setActiveItem(state,obj) {
     return state.isActive = obj
    }
  },
  actions: {}
}
